Conversation
|
Validated with below template changes, |
There was a problem hiding this comment.
Pull request overview
This PR updates the MetricAgent plugin so compute_metric rules can operate when the required operands are split across multiple matrices (instead of assuming a single object-keyed matrix), and adjusts/adds unit tests to cover the multi-matrix scenario.
Changes:
- Changed
MetricAgent.actionsto accept the fulldataMap(map[string]*matrix.Matrix) rather than a single*matrix.Matrix. - Updated
computeMetricsto select operand matrices per rule/operand (enabling multi-matrix support). - Updated the single-matrix test to run through
Run(), and added a new multi-matrix test case.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cmd/poller/plugin/metricagent/parse_rules.go | Updates action function signature to accept the full matrix map. |
| cmd/poller/plugin/metricagent/metric_agent.go | Passes dataMap through actions and updates compute logic for multi-matrix operands. |
| cmd/poller/plugin/metricagent/metric_agent_test.go | Renames/updates existing test to call Run() and adds a multi-matrix test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| metricVal = a.getMetric(m, r.metricNames[i]) | ||
| if metricVal != nil { | ||
| v, _ = metricVal.GetValueFloat64(instance) | ||
| if m[i] != nil && m[i].GetInstance(iKey) != nil { |
There was a problem hiding this comment.
SG metrics seems to have an index https://github.com/NetApp/harvest/blob/main/cmd/collectors/storagegrid/storagegrid.go#L219
Would getting by name work?
There was a problem hiding this comment.
Yes, validated locally and it's able to apply the given operator on the same instance of both metrics.
mat.NewInstance(metricName + "-" + strconv.Itoa(i)); Yes, it has index in instanceKey generation, but we use that instance key as-is for all m arrays.
Added supporting test cases as well.